package pta.newch04.ex29;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            Student student = new Student();
            student.display();
            String name = scanner.next();
            int age = scanner.nextInt();
            student.setName(name);
            student.setAge(age);
            student.display();
        }
        scanner.close();
    }
}

class Student {
    private String name;
    private int age;

    public Student() {
        this.age = 7;
        this.name = "无名";
        System.out.println("无参构造方法");
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        if (age <= 6) {
            this.age = 7;
        } else {
            this.age = age;
        }
    }

    public void display() {
        System.out.println("name:" + name + ",age:" + age);
    }
}